﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using AForge.Video.DirectShow;

namespace CokAracliKontrol
{
    public partial class CameraSelection : Form
    {
        FilterInfoCollection localCameras;
        private string camera;

        public string localCamera
        {
            get 
            { 
                return camera;
            }
        }

        public CameraSelection()
        {
            InitializeComponent();
            
            try
            {
                localCameras = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                if (localCameras.Count == 0)
                {
                    throw new ApplicationException();
                }

                foreach (FilterInfo camera in localCameras)
                {
                    cbCameraList.Items.Add(camera.Name);
                }
            }
            catch (ApplicationException)
            {

                cbCameraList.Items.Add("Please connect a camera");
                cbCameraList.Enabled = false;
                btnCameraSelectionOK.Enabled = false;
            }

            cbCameraList.SelectedIndex = 0;
        }

        private void btnCameraSelectionOK_Click(object sender, EventArgs e)
        {
            camera = localCameras[cbCameraList.SelectedIndex].MonikerString;
        }

        private void btnlCameraSelectionCance_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
